import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.Color;
import java.awt.SystemColor;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JTabbedPane;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;
import net.miginfocom.swing.MigLayout;
import java.awt.Component;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.swing.JFormattedTextField;
import javax.swing.SwingConstants;


public class Reservierungsverwaltung extends JFrame implements ActionListener {

	private JPanel contentPane;
	private String Name;
	private JTable jTable1 = new JTable(30, 4);
    private DefaultTableModel jTable1Model = (DefaultTableModel) jTable1.getModel();
    private JScrollPane jTable1ScrollPane = new JScrollPane(jTable1);
    private Database db;
    private JFormattedTextField formattedTextField;
    private JFormattedTextField formattedTextField_1;
    private JFormattedTextField formattedTextField_2;
    private User user;
    
	public Reservierungsverwaltung(Database db, User userObj) throws SQLException {
		this.db=db;
		this.user=userObj;
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 870, 620);
		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
	    int x = (d.width - getSize().width) / 2;
	    int y = (d.height - getSize().height) / 2;
	    setLocation(x, y);

		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		JMenuItem mntmKinoverwaltung = new JMenuItem("Kinoverwaltung");
		mntmKinoverwaltung.setFont(new Font("Verdana", Font.PLAIN, 14));
		mntmKinoverwaltung.addActionListener(this);

		menuBar.add(mntmKinoverwaltung);
		contentPane = new JPanel();
		contentPane.setBackground(new Color(51, 153, 204));
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		
		JLabel lblTakeASeat = new JLabel("Take A Seat - Reservierungsverwaltung");
		lblTakeASeat.setForeground(Color.WHITE);
		lblTakeASeat.setFont(new Font("Verdana", Font.BOLD, 36));
		
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setFont(new Font("Verdana", Font.PLAIN, 14));
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addContainerGap()
					.addComponent(lblTakeASeat, GroupLayout.PREFERRED_SIZE, 834, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(61, Short.MAX_VALUE))
				.addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 905, Short.MAX_VALUE)
		);
		gl_contentPane.setVerticalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addContainerGap()
					.addComponent(lblTakeASeat, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
					.addGap(18)
					.addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 661, Short.MAX_VALUE))
		);
		
		JPanel panel_1 = new JPanel();
		tabbedPane.addTab("Reservierungen verwalten", null, panel_1, null);
		
		jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		jTable1.getColumnModel().getColumn(0).setHeaderValue("ID");
		jTable1.getColumnModel().getColumn(1).setHeaderValue("Name");
		jTable1.getColumnModel().getColumn(2).setHeaderValue("E-Mail");
		jTable1.getColumnModel().getColumn(3).setHeaderValue("Veranstaltung");
		

		 ResultSet rs = db.getData("SELECT * FROM reservierungswunsch WHERE Abgeholt = 1");
		    
		    int row=0;
		    	    
		    while(rs.next()){
		    	    jTable1.setValueAt(rs.getString(1),row,0);
		    	    jTable1.setValueAt(rs.getString(2),row,1);
		    	    jTable1.setValueAt(rs.getString(3),row,2);
		    	 ResultSet rs2 = db.getData("SELECT FilmID FROM veranstaltungen WHERE VeranstaltungsID = " + rs.getString(5));
		    	 rs2.next(); 
		    	 System.out.println(" rs2 Filmtitel = " + rs2.getString(1));
		    	 ResultSet rs4 = db.getData("SELECT Filmtitel FROM filme WHERE Filmnummer = " + rs2.getString(1));
		    	 ResultSet rs3 = db.getData("SELECT Zeit FROM veranstaltungen WHERE VeranstaltungsID = " + rs.getString(5));
		    	 rs3.next(); 
		    	 rs4.next();
		    	 String eventtext = rs4.getString(1) + "  " + rs3.getString(1);
		    	    jTable1.setValueAt(eventtext,row,3); 
		    	   // System.out.println(rs.getString(1) + " " + rs.getString(2) + " " + rs.getString(3) + " " + rs.getString(4));
		    	    row++;
		    }
	
		
		JLabel lblId = new JLabel("ID");
		lblId.setFont(new Font("Verdana", Font.BOLD, 14));
		
		formattedTextField = new JFormattedTextField();
		
		JLabel lblName = new JLabel("Name");
		lblName.setFont(new Font("Verdana", Font.BOLD, 14));
		
		formattedTextField_1 = new JFormattedTextField();
		
		JLabel lblVeranstaltung = new JLabel("Veranstaltung");
		lblVeranstaltung.setFont(new Font("Verdana", Font.BOLD, 14));
		
		formattedTextField_2 = new JFormattedTextField();
		
		JButton btnSuchen = new JButton("Suchen");
		btnSuchen.setFont(new Font("Verdana", Font.PLAIN, 14));
		btnSuchen.addActionListener(this);
		
		JButton btnStornieren = new JButton("Stornieren");
		btnStornieren.setFont(new Font("Verdana", Font.PLAIN, 14));
		btnStornieren.addActionListener(this);
		
		JButton btnVerkauft = new JButton("Verkauft");
		btnVerkauft.setFont(new Font("Verdana", Font.PLAIN, 14));
		btnVerkauft.addActionListener(this);
		
		JButton btnScan = new JButton("Scan");
		btnScan.setFont(new Font("Verdana", Font.PLAIN, 14));
		btnScan.setOpaque(false);
		btnScan.setContentAreaFilled(false);
		GroupLayout gl_panel_1 = new GroupLayout(panel_1);
		gl_panel_1.setHorizontalGroup(
			gl_panel_1.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel_1.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_panel_1.createSequentialGroup()
							.addComponent(jTable1ScrollPane, GroupLayout.PREFERRED_SIZE, 565, GroupLayout.PREFERRED_SIZE)
							.addGap(18)
							.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
								.addComponent(btnVerkauft, GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
								.addComponent(btnScan, GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
								.addComponent(btnStornieren, GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)))
						.addGroup(gl_panel_1.createSequentialGroup()
							.addComponent(lblId)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(formattedTextField, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)
							.addGap(26)
							.addComponent(lblName, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(formattedTextField_1, GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)
							.addGap(32)
							.addComponent(lblVeranstaltung, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(formattedTextField_2, GroupLayout.PREFERRED_SIZE, 174, GroupLayout.PREFERRED_SIZE)
							.addGap(18)
							.addComponent(btnSuchen, GroupLayout.PREFERRED_SIZE, 128, GroupLayout.PREFERRED_SIZE)))
					.addGap(41))
		);
		gl_panel_1.setVerticalGroup(
			gl_panel_1.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel_1.createSequentialGroup()
					.addGap(33)
					.addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblId)
						.addComponent(formattedTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(lblName, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
						.addComponent(formattedTextField_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(lblVeranstaltung, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
						.addComponent(formattedTextField_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(btnSuchen, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE))
					.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_panel_1.createSequentialGroup()
							.addGap(123)
							.addComponent(btnStornieren, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
							.addGap(13)
							.addComponent(btnVerkauft, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addComponent(btnScan, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_panel_1.createSequentialGroup()
							.addGap(18)
							.addComponent(jTable1ScrollPane, GroupLayout.PREFERRED_SIZE, 351, GroupLayout.PREFERRED_SIZE))))
		);
		gl_panel_1.linkSize(SwingConstants.VERTICAL, new Component[] {btnStornieren, btnVerkauft, btnScan});
		panel_1.setLayout(gl_panel_1);
		contentPane.setLayout(gl_contentPane);
		setVisible(true);
	}


	public Reservierungsverwaltung(Database db2, User user2, String id,	String name2, String veranstaltung) throws SQLException {

		this.db=db2;
		this.user=user2;
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 870, 620);
		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
	    int x = (d.width - getSize().width) / 2;
	    int y = (d.height - getSize().height) / 2;
	    setLocation(x, y);

		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		JMenuItem mntmKinoverwaltung = new JMenuItem("Kinoverwaltung");
		mntmKinoverwaltung.setFont(new Font("Verdana", Font.PLAIN, 14));
		mntmKinoverwaltung.addActionListener(this);

		menuBar.add(mntmKinoverwaltung);
		contentPane = new JPanel();
		contentPane.setBackground(new Color(51, 153, 204));
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		
		JLabel lblTakeASeat = new JLabel("Take A Seat - Reservierungsverwaltung");
		lblTakeASeat.setForeground(Color.WHITE);
		lblTakeASeat.setFont(new Font("Verdana", Font.BOLD, 36));
		
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setFont(new Font("Verdana", Font.PLAIN, 14));
		GroupLayout gl_contentPane = new GroupLayout(contentPane);
		gl_contentPane.setHorizontalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addContainerGap()
					.addComponent(lblTakeASeat, GroupLayout.PREFERRED_SIZE, 834, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(61, Short.MAX_VALUE))
				.addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 905, Short.MAX_VALUE)
		);
		gl_contentPane.setVerticalGroup(
			gl_contentPane.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPane.createSequentialGroup()
					.addContainerGap()
					.addComponent(lblTakeASeat, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
					.addGap(18)
					.addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 661, Short.MAX_VALUE))
		);
		
		JPanel panel_1 = new JPanel();
		tabbedPane.addTab("Reservierungen verwalten", null, panel_1, null);
		
		formattedTextField = new JFormattedTextField();
		
		jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		jTable1.getColumnModel().getColumn(0).setHeaderValue("ID");
		jTable1.getColumnModel().getColumn(1).setHeaderValue("Name");
		jTable1.getColumnModel().getColumn(2).setHeaderValue("E-Mail");
		jTable1.getColumnModel().getColumn(3).setHeaderValue("Veranstaltung");
		
		refreshtable(id, name2, veranstaltung);
		System.out.println("Wert= " + id);
		if(id!=null)
	    formattedTextField.setText(id);
	    
		
		JLabel lblId = new JLabel("ID");
		lblId.setFont(new Font("Verdana", Font.BOLD, 14));
		
		
		
		JLabel lblName = new JLabel("Name");
		lblName.setFont(new Font("Verdana", Font.BOLD, 14));
		
		formattedTextField_1 = new JFormattedTextField();
		
		JLabel lblVeranstaltung = new JLabel("Veranstaltung");
		lblVeranstaltung.setFont(new Font("Verdana", Font.BOLD, 14));
		
		formattedTextField_2 = new JFormattedTextField();
		
		JButton btnSuchen = new JButton("Suchen");
		btnSuchen.setFont(new Font("Verdana", Font.PLAIN, 14));
		btnSuchen.addActionListener(this);
		
		JButton btnStornieren = new JButton("Stornieren");
		btnStornieren.setFont(new Font("Verdana", Font.PLAIN, 14));
		btnStornieren.addActionListener(this);
		
		JButton btnVerkauft = new JButton("Verkauft");
		btnVerkauft.setFont(new Font("Verdana", Font.PLAIN, 14));
		btnVerkauft.addActionListener(this);
		
		JButton btnScan = new JButton("Scan");
		btnScan.setFont(new Font("Verdana", Font.PLAIN, 14));
		btnScan.setOpaque(false);
		btnScan.setContentAreaFilled(false);
		GroupLayout gl_panel_1 = new GroupLayout(panel_1);
		gl_panel_1.setHorizontalGroup(
			gl_panel_1.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel_1.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_panel_1.createSequentialGroup()
							.addComponent(jTable1ScrollPane, GroupLayout.PREFERRED_SIZE, 565, GroupLayout.PREFERRED_SIZE)
							.addGap(18)
							.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
								.addComponent(btnVerkauft, GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
								.addComponent(btnScan, GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
								.addComponent(btnStornieren, GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)))
						.addGroup(gl_panel_1.createSequentialGroup()
							.addComponent(lblId)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(formattedTextField, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)
							.addGap(26)
							.addComponent(lblName, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(formattedTextField_1, GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)
							.addGap(32)
							.addComponent(lblVeranstaltung, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(formattedTextField_2, GroupLayout.PREFERRED_SIZE, 174, GroupLayout.PREFERRED_SIZE)
							.addGap(18)
							.addComponent(btnSuchen, GroupLayout.PREFERRED_SIZE, 128, GroupLayout.PREFERRED_SIZE)))
					.addGap(41))
		);
		gl_panel_1.setVerticalGroup(
			gl_panel_1.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel_1.createSequentialGroup()
					.addGap(33)
					.addGroup(gl_panel_1.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblId)
						.addComponent(formattedTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(lblName, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
						.addComponent(formattedTextField_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(lblVeranstaltung, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
						.addComponent(formattedTextField_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(btnSuchen, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE))
					.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_panel_1.createSequentialGroup()
							.addGap(123)
							.addComponent(btnStornieren, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
							.addGap(13)
							.addComponent(btnVerkauft, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addComponent(btnScan, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE))
						.addGroup(gl_panel_1.createSequentialGroup()
							.addGap(18)
							.addComponent(jTable1ScrollPane, GroupLayout.PREFERRED_SIZE, 351, GroupLayout.PREFERRED_SIZE))))
		);
		gl_panel_1.linkSize(SwingConstants.VERTICAL, new Component[] {btnStornieren, btnVerkauft, btnScan});
		panel_1.setLayout(gl_panel_1);
		contentPane.setLayout(gl_contentPane);
		setVisible(true);

	}


	@Override
	public void actionPerformed(ActionEvent e){
		if (e.getActionCommand()=="Kinoverwaltung"){
			dispose();
			try {
				new Kinoverwaltung(db, user);//.main(null);
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
		if (e.getActionCommand()=="Suchen"){
			String id = formattedTextField.getText();
			String name = formattedTextField.getText();
			String veranstaltung = formattedTextField.getText();
			
			dispose();
			try {
				new Reservierungsverwaltung(db, user, id, name, veranstaltung);
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
		if(e.getActionCommand()=="Stornieren"){
			try {
				db.stornoReservierung(Integer.parseInt((String) jTable1.getValueAt(jTable1.getSelectedRow(), 0)));
			} catch (NumberFormatException | SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			dispose();
			try {
				new Reservierungsverwaltung(db,user);
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
		if(e.getActionCommand()=="Verkauft"){
			try {
				db.verkauftReservierung(Integer.parseInt((String) jTable1.getValueAt(jTable1.getSelectedRow(), 0)));
			} catch (NumberFormatException | SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			dispose();
			try {
				new Reservierungsverwaltung(db,user);
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
	}
	
	public void refreshtable(String id,String name,String veranstaltung) throws SQLException {
		
		
		ResultSet rs =null;
		
		if(id!=null){
			rs = db.getData("SELECT * FROM reservierungswunsch WHERE ReservierungswunschID = " + Integer.parseInt(id));
		    System.out.println("id nummer = " + id);
		}
		else if(name!=null){
			rs = db.getData("SELECT * FROM reservierungswunsch WHERE Abgeholt = 1");
			System.out.println("Name = " + name);
		}
		else if(veranstaltung!=null){
			rs = db.getData("SELECT * FROM reservierungswunsch WHERE Abgeholt = 1");
			System.out.println("veranstaltung = " + veranstaltung);
		}
		else{
			rs = db.getData("SELECT * FROM reservierungswunsch WHERE Abgeholt = 1");
			System.out.println("Keine Engabe im Filter");
		}
		    
		    int row=0;
		    	    
		    while(rs.next()){
		    	    jTable1.setValueAt(rs.getString(1),row,0);
		    	    jTable1.setValueAt(rs.getString(2),row,1);
		    	    jTable1.setValueAt(rs.getString(3),row,2);
		    	 ResultSet rs2 = db.getData("SELECT FilmID FROM veranstaltungen WHERE VeranstaltungsID = " + rs.getString(5));
		    	 rs2.next(); 
		    	 System.out.println(" rs2 Filmtitel = " + rs2.getString(1));
		    	 ResultSet rs4 = db.getData("SELECT Filmtitel FROM filme WHERE Filmnummer = " + rs2.getString(1));
		    	 ResultSet rs3 = db.getData("SELECT Zeit FROM veranstaltungen WHERE VeranstaltungsID = " + rs.getString(5));
		    	 rs3.next(); 
		    	 rs4.next();
		    	 String eventtext = rs4.getString(1) + "  " + rs3.getString(1);
		    	    jTable1.setValueAt(eventtext,row,3); 
		    	    row++;
		    }
		    
		    setVisible(true);
		}
		
		
	}

